package io.bdmc.modules.bss.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.bdmc.common.annotation.Excel;
import io.bdmc.common.annotation.Excels;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 实体
 * </p>
 *
 * @author 黄露
 * @since 2021-05-21
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
// "DeviceMachineOpm对象", description = "")
public class DeviceMachineOpm extends Model<DeviceMachineOpm> {

  private static final long serialVersionUID = 1L;

  @TableId(value = "machine_opm_id", type = IdType.AUTO)
  private Integer machineOpmId;

  // "设备id")
  private Integer deviceId;

  @Excel(name = "单盘sn")
  private String diskSn;

  // "设备主类型+设备子类型")
  private String deviceType;

  @Excel(name = "盘类型",readConverterExp = "1=光功率计,2=光源,3=光源+光功率计")
  private String pmType;

  @Excel(name = "光功率端口")
  private String pmPort;

  @Excel(name = "波长")
  @TableField(exist = false)
  private  String wavelength1;

  @TableField(exist = false)
  @Excels({ @Excel(name = "功率", targetAttr = "lightPower", type = Excel.Type.EXPORT)})
  private List<DeviceMachineOpmModule> opmModuleList;

  @Excel(name = "创建时间")
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private LocalDateTime createTime;

  // "更新时间")
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private LocalDateTime updateTime;

  private Boolean intervalSave;


  public String getWavelength1() {
    if(opmModuleList!=null&&opmModuleList.size()>0){
      return opmModuleList.get(0).getWavelength();
    }
    return "";
  }

  @Override
  public Serializable pkVal() {
    return this.machineOpmId;
  }



}
